﻿define(function (require) {
    require('ezdesk/utility/datetime');

    var service = require('ezdesk/utility/service');
    var currentUser = service.CurrentUser_CacheSync();

    window.Feed = Backbone.Model.extend({
        initialize: function () {
            if (!this.get("CreateOnNiceTime")) {
                this.set({ "CreateOnNiceTime":
                    Date.fromEpoch(this.get("UpdateOn")).format("HH:mm")
                });
            }
            if (!this.get("FullDateAndDay")) {
                this.set({ "FullDateAndDay":
                    Date.fromEpoch(this.get("UpdateOn")).toFullDateAndDay()
                });
            }
            if (!this.get("NiceTime")) {
                this.set({ "NiceTime":
                    Date.fromEpoch(this.get("UpdateOn")).toNiceTime()
                });
            }

        },
        setIsRead: function (isRead) {
            this.set({ "IsRead": isRead });

            service.UpdateFeedStatus(function (e) {

            }, {
                feedId: this.get('FeedId'),
                isRead: true,
                memberString: currentUser.Id
            });
        },
        setIsAvailable: function () {
            service.UpdateFeedStatus(function (e) {
            
            }, {
                feedId: this.get('FeedId'), 
                isAvailable: false, 
                memberString: currentUser.Id 
            });
        }
    });

});
